<include file="default_header"/>

<body>
<div class="wraper">
    <div class="header bg-blue">
        <p class="iconfont icon-iconfontlaoshifengcai"></p>
        <p>店主注册</p>
        <a href="javascript:history.back(-1)" class="back"><img src="/assets/base/center/images/return.png"/></a>
    </div>
    <div class="container">
        <p class="tips margin-b" style="display: none;">您的注册提交后需要等待工作人员审核。</p>
        <div class="form-list margin-b clearfix">
            <span class="field pull-left">姓名</span>
            <input class="form-control pull-left" placeholder="请输入您的真实姓名" id="real_name" value="{BEESCRM:$user['real_name']}"/>
            <p class="tips-icon">
                <span class="iconfont icon-zhengque icon-green" id="right2"></span>
                <span class="iconfont icon-cuowu icon-red" id="wrong2"></span>
            </p>
        </div>
        <div class="form-list margin-b clearfix">
            <span class="field pull-left">身份证号</span>
            <input class="form-control pull-left" placeholder="请输入您的身份证号" id="id_card" value="{BEESCRM:$user['id_card']}"/>
            <p class="tips-icon">
                <span class="iconfont icon-zhengque icon-green" id="right"></span>
                <span class="iconfont icon-cuowu icon-red" id="wrong"></span>
            </p>
        </div>
        <div class="form-list margin-b clearfix">
            <span class="field pull-left">手机</span>
            <input class="form-control pull-left" placeholder="请输入您的手机号码" id="mobile" value="{BEESCRM:$user['mobile']}"/>
            <p class="tips-icon">
                <span class="iconfont icon-zhengque icon-green" id="right3"></span>
                <span class="iconfont icon-cuowu icon-red" id="wrong3"></span>
            </p>
        </div>
        <p class="tips validation-tips margin-b"></p>
        <div class="btn-box margin-b">
            <a href="javascript:void(0);" class="btn register">提交</a>
        </div>
    </div>
    <input type="hidden" id="type" value="2">
    <if condition="$remark">
        <include file="remark"/>
    </if>
    <div class="bottom-box">
        <p class="copyright">杭州青橄榄网络技术有限公司 技术支持</p>
    </div>
</div>

<include file="common_js"/>
<script type="text/javascript">
    // 验证
    $('#id_card').bind('input propertychage',function(){
        var id_card = $(this).val();
        if(id_card.length !== 18){
            notice('#id_card', 'wrong');
            return false;
        }
    });




    $('#mobile').bind('input propertychange', function() {
        var mobile = $("#mobile").val();
        if($.validatePhoneNumber(mobile)){
            $(this).siblings().find('.iconfont').hide();
            $(this).siblings().find('#right').show();
        }else{
            $(this).siblings().find('.iconfont').hide();
            $(this).siblings().find('#wrong').show();
        }
    });


    var height = $(window).height();
    var bottombox_height = $('.bottom-box').outerHeight();
    $('.wraper').css("minHeight", height);
    $('.wraper').css("paddingBottom", bottombox_height);

    // 验证提示
    function notice(elem, class_name){
        $(elem).siblings().find('.iconfont').hide();
        $(elem).siblings().find('#' + class_name).show();
    }

    $(document).on('click','.register',function(){
        var data = {};
        var verify_method = /^(?:13\d|15\d|18\d|17\d|14\d)\d{5}(\d{3}|\*{3})$/;
        data.id_card = $('#id_card').val();
        data.real_name = $('#real_name').val();
        data.mobile = $('#mobile').val();
        data.smsVerifyCode = $('#smsVerifyCode').val();
        data.type = $('#type').val();

        if (!data.id_card || data.id_card.length != 18) {
            $('.validation-tips').html('请输入正确的身份证号').show();
            return false;
        } else if (!data.real_name) {
            $('.validation-tips').html('姓名不能为空').show();
            return false;
        } else if(!data.mobile){
            $('.validation-tips').html('手机号不能为空').show();
            return false;
        }else if (!verify_method.test(data.mobile)) {
            $('.validation-tips').html('请输入正确的手机号').show();
            return false;
        }

        var json = {};
        json.method = 'post';
        json.type = 'json';
        json.url = "{BEESCRM::U('/base/User/doRegisterUtilities',array('account_id'=>$accountId ,'type' => 2))}";
        json.data = data;
        $.getAjax(json, true, reload, '');

    });
    function reload(data){
        var type = data.type;
        location.href="{BEESCRM::U('/base/User/tips',array('account_id'=>$accountId))}/type/"+type;
        //setTimeout("location.href ='{BEESCRM::U('base/center/center',array('wechat_id'=>$wechat_id))}'", 2000);
    }
</script>
</body>
</html>